package a2023.a0323;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * @author lenovo
 * @date 2023/3/23
 */
public class a {
    public static void main(String[] args) {
        System.out.println(checkArithmeticSubarrays(new int[]{4, 6, 5, 9, 3, 7}, new int[]{0, 0, 2}, new int[]{2, 3, 5}));
    }
    public static List<Boolean> checkArithmeticSubarrays(int[] nums, int[] l, int[] r) {
        int len = l.length;
        List<Boolean> list = new ArrayList<Boolean>(len);
        //截取
        for (int i = 0; i < len; i++) {
            int[] ints = Arrays.copyOfRange(nums, l[i], r[i]+1);
            Arrays.sort(ints);
            //判断
            int tempVal = ints[1]-ints[0];
            boolean alltrue = true;
            for (int i1 = 1; i1 < ints.length-1; i1++) {
                if (ints[i1+1]-ints[i1]!=tempVal){
                    list.add(false);
                    alltrue = false;
                    break;
                }
            }
            if (alltrue){
                list.add(true);
            }
            System.out.println(Arrays.toString(ints));
        }
        return list;
    }
}
